<template>
  <basic-dialog
    width="60%"
    title="修改日志查看"
    :visible="visible"
    :showFooter="false"
    :handleClose="handleCloseDialog"
  >
    <BasicTable
      :showSelectCol="false"
      :loading="tableInfo.loading"
      :columns="tableInfo.columns"
      :dataSource="tableInfo.list"
      :pagination="pagination"
      :pageSizes="pageSizes"
      :tableHeight="480"
      @pageChange="handlePageChange"
      @pageSizeChange="handlePageSizeChange"
    />
  </basic-dialog>
</template>
<script>
import BasicDialog from '@/components/BasicDialog';
import BasicTable from '@/components/BasicTable';
import basePage from '@/mixins/commodity/basePage';
import { queryModifyLogService } from '@/api/commodity/temporaryPurchasingGoods/temporaryProjectGoods'
export default {
  mixins: [basePage],
  components: {
    BasicDialog,
    BasicTable
  },
  props: {
    visible: Boolean,
    skuNo: {
      type: String,
      required: true
    }
  },
  data () {
    return {
      tableInfo: {
        list: [],
        columns: [
          { title: '创建人',  key: 'createOperName' },
          { title: '创建时间',  key: 'createOpeTime' },
          { title: 'SKU编码',  key: 'skuNo' },
          { title: '内容',  key: 'content' }
        ],
        loading: false
      }
    }
  },
  watch: {
    visible (val) {
      val && this.getTableData();
    }
  },
  methods: {
    // 获取表格数据
    async getTableData () {
      const data = { searchParam: this.skuNo, ...this.paginationParams };
      const loadingFn = state => { this.tableInfo.loading = state };
      const res = await queryModifyLogService(data, loadingFn);
      if (res?.retData?.results) {
        this.tableInfo.list = res.retData.results ?? [];
        this.pagination.totalNum = res.retData?.totalNum ?? 0;
      }
    },
    // 关闭弹框
    handleCloseDialog () {
      this.$emit('update:visible', false);
    },
  }
}
</script>
